package cn.iocoder.yudao.framework.location;

import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.thirdparty.amap.AmapLocationClient;
import cn.iocoder.yudao.framework.thirdparty.tencent.TencentLocationClient;
import cn.iocoder.yudao.framework.thirdparty.tianditu.TiandituLocationClient;
import jakarta.annotation.Nonnull;

import java.util.List;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  这里是文件说明
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/05/17
 */
public class LocationClientFactory {

    public static LocationClient createDefault() {
        return create(LocationProvider.Default);
    }

    public static LocationClient createRandom() {
        List<LocationProvider> providers = List.of(
                LocationProvider.AMap,
                LocationProvider.Tencent,
                LocationProvider.Tianditu
        );
        LocationProvider provider = providers.get(RandomUtil.randomInt(providers.size()));
        return create(provider);
    }

    public static LocationClient create(@Nonnull LocationProvider provider) {
        LocationClient client;
        if (LocationProvider.AMap.equals(provider)) {
            client = new AmapLocationClient();
        } else if (LocationProvider.Tencent.equals(provider)) {
            client = new TencentLocationClient();
        } else if (LocationProvider.Tianditu.equals(provider)) {
            client = new TiandituLocationClient();
        } else {
            client = new DefaultLocationClient();
        }
        return client;
    }

}
